package com.tom.demo.array;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Objects;
import java.util.stream.Collectors;

public class Test27_RemoveElement {
    public static void main(String[] args) {
        int[] nums = new int[]{3, 2, 2, 3};
        int val = 3;
        removeElement(nums, val);
    }

    public static int removeElement(int[] nums, int val) {
        for (int i = 0; i < nums.length; i++) {
            if (Objects.equals(nums[i], val)) {
                nums[i] = 99999;
            }
        }
        Arrays.sort(nums);
        return Long.valueOf(Arrays.stream(nums).filter(n->n!=99999).count()).intValue();
    }
}
